package controller;

import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import model.Player;

/**
 * Changes the tempo of the Player when a change is detected.
 */
public class TempoChangeListener implements ChangeListener {

	private Player player;

	public TempoChangeListener(Player player) {
		this.player = player;
	}

	@Override
	public void stateChanged(ChangeEvent e) {
		Object obj = e.getSource();
		if(obj instanceof JSlider) {
			player.setTempo(((JSlider)obj).getValue());
		}
	}

}
